home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume20 / deliver2.0 / patch1 < prev    next >
Encoding:
Internet Message Format  |  1989-10-15  |  24.8 KB

  1. Subject:  v20i027:  Deliver, flexible email delivery system, Patch1
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Chip Salzenberg <chip@ateng.com>
  7. Posting-number: Volume 20, Issue 27
  8. Archive-name: deliver2.0/patch1
  9. Patch-to: deliver2.0
  10.  
  11. Changes in patch #1 to Deliver 2.0:
  12.  
  13. 1.  If a delivery file produces no output, the message isn't thrown
  14.     away.  Instead, it is put in an "undelivered mail" mailbox.  This
  15.     change should prevent lost mail due to broken delivery files.
  16.  
  17. 2.  If a delivery file outputs the string "DROP", the "undelivered mail"
  18.     safety net is removed.  Think of this as: "Yes, I want to toss it."
  19.  
  20. 3.  Don't bother to recopy temp files when executing system and post-
  21.     user delivery files.  There's no security problem with them.
  22.  
  23. 4.  New configuration items:
  24.     SAFEPATH        Safe directories for PATH environment var.
  25.     MBX_UNDEL       Mailbox for undelivered mail.
  26.     DFILE_DROP      Special delivery file output string:  "Drop msg."
  27.  
  28. 5.  New sample delivery file, "u-notify".  This one writes a message on
  29.     your terminal when new mail arrives.
  30.  
  31. 6.  Miscellaneous bug fixes.
  32.  
  33. This patch contains changes to the following files:
  34.     patchlevel.h
  35.     Makefile
  36.     config.h
  37.     copymsg.c
  38.     deliver.8
  39.     deliver.h
  40.     dest.c
  41.     dfile.c
  42.     misc.h
  43.     procs.c
  44.     subs.c
  45.     samples/u-notify
  46.  
  47. #! /bin/sh
  48. # This is a shell archive.  Remove anything before this line, then unpack
  49. # it by saving it into a file and typing "sh file".  To overwrite existing
  50. # files, type "sh file -c".  You can also feed this as standard input via
  51. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  52. # will see the following message at the end:
  53. #        "End of shell archive."
  54. # Contents:  patch1
  55. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  56. if test -f 'patch1' -a "${1}" != "-c" ; then 
  57.   echo shar: Will not clobber existing file \"'patch1'\"
  58. else
  59. echo shar: Extracting \"'patch1'\" \(22320 characters\)
  60. sed "s/^X//" >'patch1' <<'END_OF_FILE'
  61. X
  62. XIndex: patchlevel.h
  63. XPrereq: 0
  64. X***************
  65. X*** 1,1 ****
  66. X! #define PATCHLEVEL 0
  67. X--- 1,1 ----
  68. X! #define PATCHLEVEL 1
  69. X
  70. XIndex: Makefile
  71. X***************
  72. X*** 1,3 ****
  73. X! # $Header: Makefile,v 2.2 89/06/09 13:19:53 network Exp $
  74. X  #
  75. X  # Makefile for deliver
  76. X--- 1,3 ----
  77. X! # $Header: Makefile,v 2.4 89/10/02 10:58:56 network Exp $
  78. X  #
  79. X  # Makefile for deliver
  80. X***************
  81. X*** 29,32 ****
  82. X--- 29,35 ----
  83. X  #       Your local sharchive generator.
  84. X  #
  85. X+ # CC
  86. X+ #       Your favorite C compiler.
  87. X+ #
  88. X  # CFLAGS
  89. X  #       Compile-time flags to cc.
  90. X***************
  91. X*** 33,36 ****
  92. X--- 36,40 ----
  93. X  #       For BSD systems, include "-DBSD".
  94. X  #       For USG (System III and System V) systems, include "-DUSG".
  95. X+ #       For Xenix systems, don't define anything.
  96. X  #
  97. X  # LDFLAGS
  98. X***************
  99. X*** 43,49 ****
  100. X  # BIN
  101. X  #       Target directory for installation; /usr/bin is recommended.
  102. X! #       You may use /usr/local/bin (or whatever), but you must be sure
  103. X! #       that the directory you choose is in your PATH during mail
  104. X! #       transmission and delivery.
  105. X  #
  106. X  # DELSHAR
  107. X--- 47,53 ----
  108. X  # BIN
  109. X  #       Target directory for installation; /usr/bin is recommended.
  110. X! #       You may use /usr/local/bin (or whatever), but if you do,
  111. X! #       be sure that the directory you choose is in your SAFEPATH
  112. X! #       as defined in config.h.
  113. X  #
  114. X  # DELSHAR
  115. X***************
  116. X*** 54,57 ****
  117. X--- 58,62 ----
  118. X  COPY =  cp
  119. X  SHAR =  shar
  120. X+ CC = cc
  121. X  CFLAGS = -O
  122. X  LDFLAGS = -i
  123. X***************
  124. X*** 71,76 ****
  125. X  DELSRC1 = context.c copymsg.c
  126. X  DELSRC2 = debug.c dest.c dfile.c lock.c main.c
  127. X! DELSRC3 = mbox.c procs.c subs.c sysdep.c unctime.y uucp.c
  128. X! DELSRCS = $(DELSRC1) $(DELSRC2) $(DELSRC3)
  129. X  UIDSRCS = uid.c
  130. X  HDRSRCS = header.c
  131. X--- 76,84 ----
  132. X  DELSRC1 = context.c copymsg.c
  133. X  DELSRC2 = debug.c dest.c dfile.c lock.c main.c
  134. X! DELSRC3 = mbox.c procs.c subs.c sysdep.c uucp.c
  135. X! DELYY   = unctime.y
  136. X! DELYC   = unctime.c
  137. X! DELSRCY = $(DELSRC1) $(DELSRC2) $(DELSRC3) $(DELYY)
  138. X! DELSRCC = $(DELSRC1) $(DELSRC2) $(DELSRC3) $(DELYC)
  139. X  UIDSRCS = uid.c
  140. X  HDRSRCS = header.c
  141. X***************
  142. X*** 126,132 ****
  143. X      $(CC) $(LDFLAGS) -o $@ $(DELOBJS) $(COMOBJS) $(LIBS)
  144. X  $(DELOBJS): $(HDRS)
  145. X  
  146. X  clean::
  147. X!     rm -f $(DELOBJS)
  148. X  clobber::
  149. X      rm -f deliver
  150. X--- 134,141 ----
  151. X      $(CC) $(LDFLAGS) -o $@ $(DELOBJS) $(COMOBJS) $(LIBS)
  152. X  $(DELOBJS): $(HDRS)
  153. X+ unctime.o: unctime.c
  154. X  
  155. X  clean::
  156. X!     rm -f $(DELOBJS) $(DELYC)
  157. X  clobber::
  158. X      rm -f deliver
  159. X***************
  160. X*** 170,175 ****
  161. X  lint: deliver.lint uid.lint
  162. X  
  163. X! deliver.lint: $(HDRS) $(DELSRCS) $(COMSRCS)
  164. X!     lint $(DELSRCS) $(COMSRCS) -lc $(LIBS) >$@
  165. X  
  166. X  uid.lint: config.h $(UIDSRCS) $(COMSRCS)
  167. X--- 179,184 ----
  168. X  lint: deliver.lint uid.lint
  169. X  
  170. X! deliver.lint: $(HDRS) $(DELSRCC) $(COMSRCS)
  171. X!     lint $(DELSRCC) $(COMSRCS) -lc $(LIBS) >$@
  172. X  
  173. X  uid.lint: config.h $(UIDSRCS) $(COMSRCS)
  174. X***************
  175. X*** 190,195 ****
  176. X  $(DELSHAR).03: $(DELSRC2)
  177. X      $(SHAR) >$@ $(DELSRC2)
  178. X! $(DELSHAR).04: $(DELSRC3)
  179. X!     $(SHAR) >$@ $(DELSRC3)
  180. X  
  181. X  clobber::
  182. X--- 199,204 ----
  183. X  $(DELSHAR).03: $(DELSRC2)
  184. X      $(SHAR) >$@ $(DELSRC2)
  185. X! $(DELSHAR).04: $(DELSRC3) $(DELYY)
  186. X!     $(SHAR) >$@ $(DELSRC3) $(DELYY)
  187. X  
  188. X  clobber::
  189. X
  190. XIndex: config.h
  191. X***************
  192. X*** 1,3 ****
  193. X! /* $Header: config.h,v 2.2 89/06/09 13:07:38 network Exp $
  194. X   *
  195. X   * Deliver configuration.
  196. X--- 1,3 ----
  197. X! /* $Header: config.h,v 2.3 89/09/29 18:16:52 network Exp $
  198. X   *
  199. X   * Deliver configuration.
  200. X***************
  201. X*** 4,7 ****
  202. X--- 4,12 ----
  203. X   *
  204. X   * $Log:    config.h,v $
  205. X+  * Revision 2.3  89/09/29  18:16:52  network
  206. X+  * Save message when delivery file produces no output,
  207. X+  * unless delivery file output the "DROP" string.
  208. X+  * Don't recopy temp files for sys and post-user delfiles.
  209. X+  * 
  210. X   * Revision 2.2  89/06/09  13:07:38  network
  211. X   * Adapt to BSD quirks.
  212. X***************
  213. X*** 58,62 ****
  214. X   */
  215. X  
  216. X! #ifdef __STDC__
  217. X  #define SIGFLAG sig_atomic_t
  218. X  #else
  219. X--- 63,67 ----
  220. X   */
  221. X  
  222. X! #if __STDC__
  223. X  #define SIGFLAG sig_atomic_t
  224. X  #else
  225. X***************
  226. X*** 127,131 ****
  227. X   */
  228. X  
  229. X! #ifdef __STDC__
  230. X  #define HAS_STDARG
  231. X  #else
  232. X--- 132,136 ----
  233. X   */
  234. X  
  235. X! #if __STDC__
  236. X  #define HAS_STDARG
  237. X  #else
  238. X***************
  239. X*** 177,180 ****
  240. X--- 182,197 ----
  241. X  
  242. X  /*----------------------------------------------------------------------
  243. X+  * Safe directories for child processes' PATH variables.
  244. X+  * Note that including "." is a security hole.
  245. X+  * For the superuser, "/etc:" is automatically prepended.
  246. X+  */
  247. X+ 
  248. X+ #ifdef BSD
  249. X+ #define SAFEPATH  "/bin:/usr/ucb:/usr/bin"
  250. X+ #else
  251. X+ #define SAFEPATH  "/bin:/usr/bin"
  252. X+ #endif
  253. X+ 
  254. X+ /*----------------------------------------------------------------------
  255. X   * Characters that may not appear in addresses.
  256. X   * (This string should include all metacharacters for your chosen shell.)
  257. X***************
  258. X*** 198,201 ****
  259. X--- 215,220 ----
  260. X   * Define MBX_MODE to the file access modes for new mailboxes.
  261. X   * (System V requires group write permissions, i.e. 0020.)
  262. X+  *
  263. X+  * Define MBX_UNDEL to the mailbox for undelivered mail.
  264. X   */
  265. X  
  266. X***************
  267. X*** 211,215 ****
  268. X--- 230,244 ----
  269. X  #endif
  270. X  
  271. X+ #define MBX_UNDEL     "Undel.mail"
  272. X+ 
  273. X  /*----------------------------------------------------------------------
  274. X+  * Delivery file directives.
  275. X+  * When delivery files output these strings as "user names", they
  276. X+  * are considered instructions.
  277. X+  */
  278. X+ 
  279. X+ #define DFILE_DROP    "DROP"            /* Drop this message    */
  280. X+ 
  281. X+ /*----------------------------------------------------------------------
  282. X   * Names of delivery files.
  283. X   *
  284. X
  285. XIndex: copymsg.c
  286. X***************
  287. X*** 1,3 ****
  288. X! /* $Header: copymsg.c,v 2.1 89/06/09 12:25:16 network Exp $
  289. X   *
  290. X   * Take the message from standard input and write it to two temp files,
  291. X--- 1,3 ----
  292. X! /* $Header: copymsg.c,v 2.2 89/09/29 18:17:53 network Exp $
  293. X   *
  294. X   * Take the message from standard input and write it to two temp files,
  295. X***************
  296. X*** 5,8 ****
  297. X--- 5,13 ----
  298. X   *
  299. X   * $Log:    copymsg.c,v $
  300. X+  * Revision 2.2  89/09/29  18:17:53  network
  301. X+  * Save message when delivery file produces no output,
  302. X+  * unless delivery file output the "DROP" string.
  303. X+  * Don't recopy temp files for sys and post-user delfiles.
  304. X+  * 
  305. X   * Revision 2.1  89/06/09  12:25:16  network
  306. X   * Update RCS revisions.
  307. X***************
  308. X*** 344,349 ****
  309. X  
  310. X  /*----------------------------------------------------------------------
  311. X   * Create another copy of each temp file, for security reasons.
  312. X!  * Also, put their names in the environment.
  313. X   */
  314. X  
  315. X--- 349,379 ----
  316. X  
  317. X  /*----------------------------------------------------------------------
  318. X+  * Don't bother copying message.
  319. X+  * Put the original names in the environment.
  320. X+  */
  321. X+ 
  322. X+ int
  323. X+ dont_copy()
  324. X+ {
  325. X+     int     r, t;
  326. X+ 
  327. X+     for (r = T_HDR, t = T_HDRCOPY; r <= T_BODY; ++r, ++t)
  328. X+     {
  329. X+         if (tenv[t] && tfile[r])
  330. X+             alloc_env(tenv[t], tfile[r]);
  331. X+     }
  332. X+ 
  333. X+     if (verbose)
  334. X+     {
  335. X+         message("dont_copy: header is %s, body is %s\n",
  336. X+             tfile[T_HDR], tfile[T_BODY]);
  337. X+     }
  338. X+ 
  339. X+     return 0;
  340. X+ }
  341. X+ 
  342. X+ /*----------------------------------------------------------------------
  343. X   * Create another copy of each temp file, for security reasons.
  344. X!  * Also, put the names of the copies in the environment.
  345. X   */
  346. X  
  347. X
  348. XIndex: deliver.8
  349. X***************
  350. X*** 1,3 ****
  351. X! .\" $Header: deliver.8,v 2.1 89/06/09 12:25:19 network Exp $
  352. X  .\"
  353. X  .\" Man page for deliver.
  354. X--- 1,3 ----
  355. X! .\" $Header: deliver.8,v 2.2 89/10/04 10:49:10 network Exp $
  356. X  .\"
  357. X  .\" Man page for deliver.
  358. X***************
  359. X*** 4,7 ****
  360. X--- 4,10 ----
  361. X  .\"
  362. X  .\" $Log:    deliver.8,v $
  363. X+ .\" Revision 2.2  89/10/04  10:49:10  network
  364. X+ .\" Document the "Undel.mail" and "DROP" features.
  365. X+ .\" 
  366. X  .\" Revision 2.1  89/06/09  12:25:19  network
  367. X  .\" Update RCS revisions.
  368. X***************
  369. X*** 192,196 ****
  370. X  to control delivery to users.  Note that delivery files do
  371. X  .I not
  372. X! control delivery to explicitly named mailboxes.
  373. X  .PP
  374. X  On each system the postmaster may create a
  375. X--- 195,201 ----
  376. X  to control delivery to users.  Note that delivery files do
  377. X  .I not
  378. X! control delivery to explicitly named mailboxes.  (See the
  379. X! .B \-b
  380. X! option.)
  381. X  .PP
  382. X  On each system the postmaster may create a
  383. X***************
  384. X*** 287,307 ****
  385. X  an absolute pathname, it is interpreted relative to the home directory of
  386. X  the named user.
  387. X! .PP
  388. X! .B NOTE 1:
  389. X  When
  390. X  .I deliver
  391. X! executes a delivery file, it expects that delivery file to explicitly name
  392. X! all users (and, optionally, mailboxes) where the message should be
  393. X! delivered.  If a delivery file does not name any users in its output, then
  394. X! the message will not be delivered to anyone whose mail delivery is
  395. X! controlled by that delivery file.
  396. X  .PP
  397. X! Therefore, a user delivery file containing only "exit" will keep the given
  398. X! user from receiving any mail.  A system delivery file containing only "exit"
  399. X! will cause
  400. X! .B all
  401. X! mail to disappear.  So be careful!
  402. X! .PP
  403. X! .B NOTE 2:
  404. X  If
  405. X  .I deliver
  406. X--- 292,319 ----
  407. X  an absolute pathname, it is interpreted relative to the home directory of
  408. X  the named user.
  409. X! .SH "UNDELIVERED MAIL"
  410. X  When
  411. X  .I deliver
  412. X! executes a delivery file, it expects a complete list of all users (and,
  413. X! optionally, mailboxes) that should receive the message.  If a delivery file
  414. X! produces no output,
  415. X! .I deliver
  416. X! saves the message in the "undelivered mail" mailbox named "Undel.mail" in
  417. X! the home directory of the delivery file's owner.  (System and post-user
  418. X! delivery files are "owned" by root.)
  419. X  .PP
  420. X! Sometimes a delivery file writer really does want
  421. X! .I deliver
  422. X! to drop a message.  For example, if a delivery file stores a message by
  423. X! running "deliver -b", then there's no need for the parent
  424. X! .I deliver
  425. X! to save the message again.  A delivery file can tell
  426. X! .I deliver
  427. X! not to save the message by outputting the string "DROP".  A delivery file's
  428. X! outputting "DROP" the "undelivered mail" safety net for that delivery file.
  429. X! Think of "DROP" as shorthand for: "Trust me.  I know what I'm doing."
  430. X! However, if the delivery file outputs any names and/or addresses in addition
  431. X! to "DROP", then "DROP" has no effect.
  432. X! .SH "SECURITY"
  433. X  If
  434. X  .I deliver
  435. X***************
  436. X*** 312,316 ****
  437. X  create a security problem.
  438. X  .PP
  439. X- .B NOTE 3:
  440. X  All user delivery files are executed in the context of the user in whose
  441. X  home directory they reside.  A user's "context" includes the uid, gid, and
  442. X--- 324,327 ----
  443. X***************
  444. X*** 317,321 ****
  445. X  home directory as specified in /etc/passwd.
  446. X  .PP
  447. X- .B NOTE 4:
  448. X  For security reasons, if a user's home directory is writable to the world,
  449. X  .I deliver
  450. X--- 328,331 ----
  451. X***************
  452. X*** 322,326 ****
  453. X  will ignore any delivery file that might be found there.
  454. X  .PP
  455. X- .B NOTE 5:
  456. X  For security reasons,
  457. X  .I deliver
  458. X--- 332,335 ----
  459. X
  460. XIndex: deliver.h
  461. X***************
  462. X*** 1,3 ****
  463. X! /* $Header: deliver.h,v 2.1 89/06/09 12:25:21 network Exp $
  464. X   *
  465. X   * General pull-it-together include file.
  466. X--- 1,3 ----
  467. X! /* $Header: deliver.h,v 2.2 89/09/29 18:17:56 network Exp $
  468. X   *
  469. X   * General pull-it-together include file.
  470. X***************
  471. X*** 4,7 ****
  472. X--- 4,12 ----
  473. X   *
  474. X   * $Log:    deliver.h,v $
  475. X+  * Revision 2.2  89/09/29  18:17:56  network
  476. X+  * Save message when delivery file produces no output,
  477. X+  * unless delivery file output the "DROP" string.
  478. X+  * Don't recopy temp files for sys and post-user delfiles.
  479. X+  * 
  480. X   * Revision 2.1  89/06/09  12:25:21  network
  481. X   * Update RCS revisions.
  482. X***************
  483. X*** 71,74 ****
  484. X--- 76,80 ----
  485. X  
  486. X  char    *basename();
  487. X+ char    *relpath();
  488. X  char    *gethost();
  489. X  char    *copystr();
  490. X
  491. XIndex: dest.c
  492. X***************
  493. X*** 1,3 ****
  494. X! /* $Header: dest.c,v 2.1 89/06/09 12:25:22 network Exp $
  495. X   *
  496. X   * Operations on the list of mail destinations.
  497. X--- 1,3 ----
  498. X! /* $Header: dest.c,v 2.2 89/09/29 18:17:57 network Exp $
  499. X   *
  500. X   * Operations on the list of mail destinations.
  501. X***************
  502. X*** 4,7 ****
  503. X--- 4,12 ----
  504. X   *
  505. X   * $Log:    dest.c,v $
  506. X+  * Revision 2.2  89/09/29  18:17:57  network
  507. X+  * Save message when delivery file produces no output,
  508. X+  * unless delivery file output the "DROP" string.
  509. X+  * Don't recopy temp files for sys and post-user delfiles.
  510. X+  * 
  511. X   * Revision 2.1  89/06/09  12:25:22  network
  512. X   * Update RCS revisions.
  513. X***************
  514. X*** 75,78 ****
  515. X--- 80,85 ----
  516. X      if (class == CL_MBOX)
  517. X          d->d_mailbox = copystr(mailbox);
  518. X+     else
  519. X+         d->d_mailbox = NULL;
  520. X  
  521. X      /*
  522. X
  523. XIndex: dfile.c
  524. X***************
  525. X*** 1,3 ****
  526. X! /* $Header: dfile.c,v 2.1 89/06/09 12:25:24 network Exp $
  527. X   *
  528. X   * Filter destination(s) through delivery file(s).
  529. X--- 1,3 ----
  530. X! /* $Header: dfile.c,v 2.2 89/09/29 18:17:59 network Exp $
  531. X   *
  532. X   * Filter destination(s) through delivery file(s).
  533. X***************
  534. X*** 4,7 ****
  535. X--- 4,12 ----
  536. X   *
  537. X   * $Log:    dfile.c,v $
  538. X+  * Revision 2.2  89/09/29  18:17:59  network
  539. X+  * Save message when delivery file produces no output,
  540. X+  * unless delivery file output the "DROP" string.
  541. X+  * Don't recopy temp files for sys and post-user delfiles.
  542. X+  * 
  543. X   * Revision 2.1  89/06/09  12:25:24  network
  544. X   * Update RCS revisions.
  545. X***************
  546. X*** 31,35 ****
  547. X       */
  548. X  
  549. X!     if (stat(sys_deliver, &st) == -1)
  550. X      {
  551. X          if (verbose)
  552. X--- 36,40 ----
  553. X       */
  554. X  
  555. X!     if (stat(relpath(eff_ct->ct_home, sys_deliver), &st) == -1)
  556. X      {
  557. X          if (verbose)
  558. X***************
  559. X*** 87,92 ****
  560. X  
  561. X      if (fac > 2)
  562. X!         (void) do_dfile(eff_ct, fav, (DEST *)NULL);
  563. X  
  564. X      free((char *) fav);
  565. X  
  566. X--- 92,110 ----
  567. X  
  568. X      if (fac > 2)
  569. X!     {
  570. X!         /*
  571. X!          * If we get nothing back from the system delivery file,
  572. X!          * put the message in the "undelivered" mailbox.
  573. X!          */
  574. X  
  575. X+         if (do_dfile(eff_ct, fav, (DEST *)NULL) <= 0)
  576. X+         {
  577. X+             if (verbose)
  578. X+                 message("sys_dfile: no output\n");
  579. X+ 
  580. X+             (void) dest(eff_ct->ct_name, MBX_UNDEL);
  581. X+         }
  582. X+     }
  583. X+ 
  584. X      free((char *) fav);
  585. X  
  586. X***************
  587. X*** 110,114 ****
  588. X       */
  589. X  
  590. X!     if (stat(post_deliver, &st) == -1)
  591. X      {
  592. X          if (verbose)
  593. X--- 128,132 ----
  594. X       */
  595. X  
  596. X!     if (stat(relpath(eff_ct->ct_home, post_deliver), &st) == -1)
  597. X      {
  598. X          if (verbose)
  599. X***************
  600. X*** 136,140 ****
  601. X          ++num_dests;
  602. X  
  603. X!     fav = (char **) zalloc((num_dests + 3) * sizeof(char **));
  604. X      fav[0] = shell;
  605. X      fav[1] = post_deliver;
  606. X--- 154,158 ----
  607. X          ++num_dests;
  608. X  
  609. X!     fav = (char **) zalloc((num_dests + 3) * sizeof(char *));
  610. X      fav[0] = shell;
  611. X      fav[1] = post_deliver;
  612. X***************
  613. X*** 155,160 ****
  614. X  
  615. X      if (fac > 2)
  616. X!         (void) do_dfile(eff_ct, fav, (DEST *)NULL);
  617. X  
  618. X      free((char *) fav);
  619. X  
  620. X--- 173,191 ----
  621. X  
  622. X      if (fac > 2)
  623. X!     {
  624. X!         /*
  625. X!          * If we get nothing back from the post-user delivery file,
  626. X!          * put the message in the "undelivered" mailbox.
  627. X!          */
  628. X  
  629. X+         if (do_dfile(eff_ct, fav, (DEST *)NULL) <= 0)
  630. X+         {
  631. X+             if (verbose)
  632. X+                 message("post_dfile: no output\n");
  633. X+ 
  634. X+             (void) dest(eff_ct->ct_name, MBX_UNDEL);
  635. X+         }
  636. X+     }
  637. X+ 
  638. X      free((char *) fav);
  639. X  
  640. X***************
  641. X*** 214,219 ****
  642. X  {
  643. X      CONTEXT *ct;
  644. X!     char    *fav[4];
  645. X!     char    udel_path[100];
  646. X      struct stat st;
  647. X  
  648. X--- 245,249 ----
  649. X  {
  650. X      CONTEXT *ct;
  651. X!     char    *s, *udel_path, *fav[4];
  652. X      struct stat st;
  653. X  
  654. X***************
  655. X*** 252,257 ****
  656. X       */
  657. X  
  658. X!     (void) sprintf(udel_path, "%s/%s", ct->ct_home, user_deliver);
  659. X!     if (stat(udel_path, &st) == -1)
  660. X      {
  661. X          if (verbose)
  662. X--- 282,287 ----
  663. X       */
  664. X  
  665. X!     s = relpath(ct->ct_home, user_deliver);
  666. X!     if (stat(s, &st) == -1)
  667. X      {
  668. X          if (verbose)
  669. X***************
  670. X*** 259,267 ****
  671. X          return;
  672. X      }
  673. X  
  674. X      /*
  675. X!      * Time to run the file!
  676. X!      * We put this dest on hold, so that it will be ignored unless
  677. X!      * the delivery file names it.
  678. X       */
  679. X  
  680. X--- 289,297 ----
  681. X          return;
  682. X      }
  683. X+     udel_path = copystr(s);
  684. X  
  685. X      /*
  686. X!      * Put this destination on hold.
  687. X!      * It will be ignored unless it's named by a delivery file.
  688. X       */
  689. X  
  690. X***************
  691. X*** 268,271 ****
  692. X--- 298,305 ----
  693. X      d->d_state = ST_HOLD;
  694. X  
  695. X+     /*
  696. X+      * Time to run the file!
  697. X+      */
  698. X+ 
  699. X      fav[0] = shell;
  700. X      fav[1] = udel_path;
  701. X***************
  702. X*** 272,276 ****
  703. X      fav[2] = d->d_name;
  704. X      fav[3] = NULL;
  705. X!     (void) do_dfile(ct, fav, d);
  706. X  }
  707. X  
  708. X--- 306,324 ----
  709. X      fav[2] = d->d_name;
  710. X      fav[3] = NULL;
  711. X! 
  712. X!     if (do_dfile(ct, fav, d) <= 0)
  713. X!     {
  714. X!         /*
  715. X!          * If we get nothing back from the user delivery file,
  716. X!          * put the message in the user's "undelivered" mailbox.
  717. X!          */
  718. X! 
  719. X!         if (verbose)
  720. X!             message("one_dfile: no output\n");
  721. X! 
  722. X!         (void) dest(ct->ct_name, MBX_UNDEL);
  723. X!     }
  724. X! 
  725. X!     free(udel_path);
  726. X  }
  727. X  
  728. X***************
  729. X*** 277,280 ****
  730. X--- 325,329 ----
  731. X  /*----------------------------------------------------------------------
  732. X   * Process a delivery file.
  733. X+  * Return the count of valid destinations we got back from it.
  734. X   */
  735. X  
  736. X***************
  737. X*** 287,290 ****
  738. X--- 336,340 ----
  739. X      FILE    *fp;
  740. X      char    *name, *mailbox;
  741. X+     int     count;
  742. X  
  743. X      if (!ct)
  744. X***************
  745. X*** 301,314 ****
  746. X      }
  747. X  
  748. X!     /* Copy the temp files again */
  749. X  
  750. X!     if (copy_again() < 0)
  751. X!         return -1;
  752. X  
  753. X!     /* Allow the given user to own and read the copies */
  754. X  
  755. X!     if (give_temps(ct) < 0)
  756. X!         return -1;
  757. X  
  758. X      /* Here we go! */
  759. X  
  760. X--- 351,379 ----
  761. X      }
  762. X  
  763. X!     /*
  764. X!      * We trust the superuser not to stomp on the temp files.
  765. X!      * Other users get copies of the temp files.
  766. X!      */
  767. X  
  768. X!     if (ct->ct_uid == 0)
  769. X!     {
  770. X!         /* We trust the superuser; don't bother copying again */
  771. X  
  772. X!         if (dont_copy() < 0)
  773. X!             return -1;
  774. X!     }
  775. X!     else
  776. X!     {
  777. X!         /* Copy the temp files again */
  778. X  
  779. X!         if (copy_again() < 0)
  780. X!             return -1;
  781. X  
  782. X+         /* Allow the given user to own and read the copies */
  783. X+ 
  784. X+         if (give_temps(ct) < 0)
  785. X+             return -1;
  786. X+     }
  787. X+ 
  788. X      /* Here we go! */
  789. X  
  790. X***************
  791. X*** 326,329 ****
  792. X--- 391,396 ----
  793. X       */
  794. X  
  795. X+     count = 0;
  796. X+ 
  797. X      while (dfile_gets(fp, &name, &mailbox) >= 0)
  798. X      {
  799. X***************
  800. X*** 330,333 ****
  801. X--- 397,409 ----
  802. X          DEST    *nd;
  803. X  
  804. X+         ++count;
  805. X+ 
  806. X+         if (strcmp(name, DFILE_DROP) == 0)
  807. X+         {
  808. X+             if (verbose)
  809. X+                 message("delivery file says OK to drop\n");
  810. X+             continue;
  811. X+         }
  812. X+ 
  813. X          nd = dest(name, mailbox);
  814. X          if (nd->d_state == ST_HOLD)
  815. X***************
  816. X*** 349,355 ****
  817. X                  dest_err(nd, E_CTPERM);
  818. X          }
  819. X      }
  820. X  
  821. X!     return ct_pclose(fp);
  822. X  }
  823. X  
  824. X--- 425,436 ----
  825. X                  dest_err(nd, E_CTPERM);
  826. X          }
  827. X+ 
  828. X+         if (nd->d_state != ST_ERROR)
  829. X+             ++count;
  830. X      }
  831. X  
  832. X!     (void) ct_pclose(fp);
  833. X! 
  834. X!     return count;
  835. X  }
  836. X  
  837. X
  838. XIndex: misc.h
  839. X***************
  840. X*** 1,3 ****
  841. X! /* $Header: misc.h,v 2.1 89/06/09 12:25:35 network Exp $
  842. X   *
  843. X   * Miscellaneous definitions.
  844. X--- 1,3 ----
  845. X! /* $Header: misc.h,v 2.2 89/10/02 10:36:43 network Exp $
  846. X   *
  847. X   * Miscellaneous definitions.
  848. X***************
  849. X*** 4,7 ****
  850. X--- 4,10 ----
  851. X   *
  852. X   * $Log:    misc.h,v $
  853. X+  * Revision 2.2  89/10/02  10:36:43  network
  854. X+  * Declare exit() as void.
  855. X+  * 
  856. X   * Revision 2.1  89/06/09  12:25:35  network
  857. X   * Update RCS revisions.
  858. X***************
  859. X*** 72,75 ****
  860. X--- 75,79 ----
  861. X  extern  long    time();
  862. X  extern  void    free();
  863. X+ extern  void    exit();
  864. X  
  865. X  #ifdef DECLARE_SIGNAL
  866. X
  867. XIndex: procs.c
  868. X***************
  869. X*** 1,3 ****
  870. X! /* $Header: procs.c,v 2.1 89/06/09 12:25:37 network Exp $
  871. X   *
  872. X   * Process management and misc support.
  873. X--- 1,3 ----
  874. X! /* $Header: procs.c,v 2.2 89/09/29 18:18:03 network Exp $
  875. X   *
  876. X   * Process management and misc support.
  877. X***************
  878. X*** 4,7 ****
  879. X--- 4,12 ----
  880. X   *
  881. X   * $Log:    procs.c,v $
  882. X+  * Revision 2.2  89/09/29  18:18:03  network
  883. X+  * Save message when delivery file produces no output,
  884. X+  * unless delivery file output the "DROP" string.
  885. X+  * Don't recopy temp files for sys and post-user delfiles.
  886. X+  * 
  887. X   * Revision 2.1  89/06/09  12:25:37  network
  888. X   * Update RCS revisions.
  889. X***************
  890. X*** 174,178 ****
  891. X  int     chd;
  892. X  {
  893. X!     char    env_path[32];
  894. X  
  895. X      /*
  896. X--- 179,183 ----
  897. X  int     chd;
  898. X  {
  899. X!     char    env_path[sizeof(SAFEPATH) + 8];
  900. X  
  901. X      /*
  902. X***************
  903. X*** 199,204 ****
  904. X      /* Set up the environment */
  905. X  
  906. X!     (void) sprintf(env_path, "%s:/bin:/usr/bin",
  907. X!             ((ct->ct_uid == 0) ? "/etc" : "."));
  908. X      alloc_env("HOME", ct->ct_home);
  909. X      alloc_env("PATH", env_path);
  910. X--- 204,212 ----
  911. X      /* Set up the environment */
  912. X  
  913. X!     env_path[0] = '\0';
  914. X!     if (ct->ct_uid == 0)
  915. X!         (void) strcat(env_path, "/etc:");
  916. X!     (void) strcat(env_path, SAFEPATH);
  917. X! 
  918. X      alloc_env("HOME", ct->ct_home);
  919. X      alloc_env("PATH", env_path);
  920. X
  921. XIndex: subs.c
  922. X***************
  923. X*** 1,3 ****
  924. X! /* $Header: subs.c,v 2.1 89/06/09 12:25:39 network Exp $
  925. X   *
  926. X   * Miscellaneous subroutines.
  927. X--- 1,3 ----
  928. X! /* $Header: subs.c,v 2.2 89/09/29 18:18:05 network Exp $
  929. X   *
  930. X   * Miscellaneous subroutines.
  931. X***************
  932. X*** 4,7 ****
  933. X--- 4,12 ----
  934. X   *
  935. X   * $Log:    subs.c,v $
  936. X+  * Revision 2.2  89/09/29  18:18:05  network
  937. X+  * Save message when delivery file produces no output,
  938. X+  * unless delivery file output the "DROP" string.
  939. X+  * Don't recopy temp files for sys and post-user delfiles.
  940. X+  * 
  941. X   * Revision 2.1  89/06/09  12:25:39  network
  942. X   * Update RCS revisions.
  943. X***************
  944. X*** 27,30 ****
  945. X--- 32,40 ----
  946. X          return;
  947. X  
  948. X+     /* If it's the same value it already has, don't bother. */
  949. X+ 
  950. X+     if ((s = getenv(name)) != NULL && strcmp(s, value) == 0)
  951. X+         return;
  952. X+ 
  953. X      s = zalloc((unsigned) (strlen(name) + strlen(value) + 2));
  954. X      (void) sprintf(s, "%s=%s", name, value);
  955. X***************
  956. X*** 147,150 ****
  957. X--- 157,195 ----
  958. X  
  959. X  /*----------------------------------------------------------------------
  960. X+  * Return the given pathname relative to the given directory.
  961. X+  * No fancy checking for "." and ".." -- sorry.
  962. X+  */
  963. X+ 
  964. X+ char *
  965. X+ relpath(dir, file)
  966. X+ char    *dir, *file;
  967. X+ {
  968. X+     static  char    *path;
  969. X+     static  unsigned pathsize;
  970. X+     unsigned n;
  971. X+ 
  972. X+     if (file[0] == '/')
  973. X+         return file;
  974. X+ 
  975. X+     n = strlen(dir) + strlen(file) + 2;
  976. X+     if (pathsize < n)
  977. X+     {
  978. X+         pathsize = n + 64;      /* gas */
  979. X+         if (path)
  980. X+             path = srealloc(path, pathsize);
  981. X+         else
  982. X+             path = zalloc(pathsize);
  983. X+     }
  984. X+ 
  985. X+     (void) strcpy(path, dir);
  986. X+     n = strlen(path);
  987. X+     if (n == 0 || path[n - 1] != '/')
  988. X+         path[n++] = '/';
  989. X+     (void) strcpy(path + n, file);
  990. X+ 
  991. X+     return path;
  992. X+ }
  993. X+ 
  994. X+ /*----------------------------------------------------------------------
  995. X   * Check an address for validity.
  996. X   */
  997. X
  998. XIndex: samples/u-notify
  999. X***************
  1000. X*** 1,0 ****
  1001. X--- 1,25 ----
  1002. X+ : u-notify
  1003. X+ # A user delivery file that tells you when new mail arrives.
  1004. X+ 
  1005. X+ user="$1"
  1006. X+ 
  1007. X+ # Keep the mail.
  1008. X+ 
  1009. X+ echo $user
  1010. X+ 
  1011. X+ # Now notify myself (if I'm logged in).
  1012. X+ 
  1013. X+ T1=`who | awk '$1 == "'"$user"'" { print $2 }'`
  1014. X+ if [ "$T1" ]
  1015. X+ then
  1016. X+     # If I'm logged in multiple times,
  1017. X+     # write to the terminal that was most recently busy.
  1018. X+ 
  1019. X+     T2=`cd /dev; ls -t $T1 | sed 1q`
  1020. X+     for t in $T2
  1021. X+     do
  1022. X+       echo "\n `date '+%D %H:%M'` --" \
  1023. X+            "you have new mail from `header -f From $HEADER`" \
  1024. X+            >/dev/$t
  1025. X+     done
  1026. X+ fi
  1027. X
  1028. END_OF_FILE
  1029. if test 22320 -ne `wc -c <'patch1'`; then
  1030.     echo shar: \"'patch1'\" unpacked with wrong size!
  1031. fi
  1032. # end of 'patch1'
  1033. fi
  1034. echo shar: End of shell archive.
  1035. exit 0
  1036.